package com.yeyks.common.em.cnbooking;

/**
 * @author fuchangshuai
 * @date 2019/09/23 14:07
 */
public enum CnResponseCodeEnum {
    EXCEPTION(-1, "程序异常"),
    SUCCESS(30000, "操作成功"),
    IMPORT_XML_NULL(30001, "输入XML为空"),
    XML_FORMAT_ERROR(30002, "XML格式不正确"),
    XML_NODE_ILLEGALITY(30003, "XML节点内容不合法"),
    ACTION_ILLEGALITY(30004, "Action不合法"),
    AUTHORIZATION_OVERTIME(30005, "接口授权已到期"),
    NO_AUTHORIZATION_OVERTIME(30006, "接口未授权"),
    SECURITY_KEY_ERROR(30007, "安全码(SecurityKey)错误"),
    USERNAME_ERROR(30008, "用户名(UserName)错误"),
    PASSWORD_ERROR(30009, "密码(PassWord)错误"),
    SIGNATURE_ERROR(30010, "传入签名(Signature)错误");
    int value;
    String desc;

    CnResponseCodeEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer value() {
        return this.value;
    }

    public String desc() {
        return this.desc;
    }

    public static String getDesc(int value) {
        for (CnResponseCodeEnum cnResponseCodeEnum : values()) {
            if (cnResponseCodeEnum.value() == value) {
                return cnResponseCodeEnum.desc();
            }
        }
        return null;
    }

    public static Integer getValue(String desc) {
        for (CnResponseCodeEnum cnResponseCodeEnum : values()) {
            if (cnResponseCodeEnum.desc().equals(desc)) {
                return cnResponseCodeEnum.value();
            }
        }
        return null;
    }
}
